var express = require('express')
var router = express.Router()
var async = require('async');
var fs = require('fs')

var {
    Information
} = require('../models/user')
router.post("/api/v1/getponedata", function (req, res) {
    console.log(req.body)
    Information.find({
        phone:req.body.phone
    },function(err, docs){
        if(err){
            console.log(err)
        }
        console.log(docs)
        res.send(docs);
    })
})
router.post("/api/v1/getbhdata", function (req, res) {
    console.log(req.body)
    Information.find({
        stunumber:req.body.stunumber
    },function(err, docs){
        if(err){
            console.log("getbhdata is err")
        }
        res.send(docs);
    })
})
router.post("/api/v1/getnadata", function (req, res) {
    console.log(req.body)
    Information.find({
        name:req.body.name
    },function(err, docs){
        if(err){
            console.log("getnadata is err")
        }
        res.send(docs);
    })
})
router.post("/api/v1/gxdata", function (req, res) {
    console.log(req.body)
    Information.updateOne({
        _id: req.body._id
    }, { $set:  req.body }, function (err, docs) {
        if (err) {
            console.log(err)
            res.send(err)
        } else {
            console.log("更新成功")
            res.send("更新成功")
        }
    })
})
module.exports = router